package com.gui;

import java.awt.event.ActionListener;
import javax.swing.Timer;

/**
 * @author sad
 */
public class RepeatableTimer {
    private Timer timer;

    public RepeatableTimer(ActionListener listener, int millisecconds) {
        timer=new Timer(0, listener);
        timer.setRepeats(false);
        timer.setDelay(0);
        timer.setInitialDelay(millisecconds);
    }
    
    public void restart(){
        if(timer.isRunning()){
            timer.restart();
        }else{
            timer.start();
        }
    }
}
